# !/bin/bash

check_include_lib_exist $host_include_dir $host_lib

if [ $? -ne 0 ]; then
    echo -e "\033[31mFound HOST include directory or library : False\033[0m"
    return 1
fi

check_include_lib_exist $oplib_include_dir $oplib_lib

if [ $? -ne 0 ]; then
    echo -e "\033[31mFound OPLIB include directory or library : False\033[0m"
    return 1
fi

# Constants
txdnn_build_dir="$project_dir/build"

function build_txdnn() {
    local build_dir="$1"

    if [ -d "$build_dir" ]; then
        rm -r "$build_dir"
    fi
    mkdir -p "$build_dir"

    pushd "$build_dir" >/dev/null 2>&1
    cmake ..
    make -j
    popd >/dev/null 2>&1
}

build_txdnn "$txdnn_build_dir"